<?php
defined('_JEXEC') or die;
?>
<?php if (count($this->children[$this->category->id]) > 0 && $this->maxLevel != 0) : ?>
<ul class="subLink">
	<?php foreach($this->children[$this->category->id] as $id => $child) : ?>
		<?php
		if ($this->params->get('show_empty_categories') || $child->numitems || count($child->getChildren())) :			
		?>
		<li<?php if(($id+1)==sizeof($this->children[$this->category->id])) echo ' class="last"'?>><a href="<?php echo JRoute::_(ContentHelperRoute::getCategoryRoute($child->id));?>">
				<?php echo $this->escape($child->title); ?></a>
                <?php if ( $this->params->get('show_sublink_num_articles',1)) : ?>
           		<span>(<?php echo $child->getNumItems(true); ?>)</span>
			<?php endif ; ?>
            <?php if (count($child->getChildren()) > 0):
				$this->children[$child->id] = $child->getChildren();
				$this->category = $child;
				$this->maxLevel--;
				if ($this->maxLevel != 0) :
					echo $this->loadTemplate('sublink');
				endif;
				$this->category = $child->getParent();
				$this->maxLevel++;
			endif; ?>
		</li>	
       <?php endif; ?>
	<?php endforeach; ?>
</ul>
<?php endif; ?>

